package xuanke;

import java.util.Scanner;

public class Test {
    public void menu1() {
        System.out.println("欢迎使用选课系统" + "\n" + "菜单" + "\n" + "1.教师登录" + "\n" + "2.学生登录" + "\n");
    }

    public void menu2() {
        System.out.println("您已进入选课系统" + "\n" + "菜单" + "\n" + "1.选课" + "\n" + "2.退课" + "\n" );
    }

    public void reportError() {
        System.out.println("您的输入有误ֹ");
    }

    public void fengexian() {
        for (int i = 1; i <= 10; i++) {
            System.out.print("-----");
        }
        ;
        System.out.println();
    }

    public static void main(String[] args) {
        Test TS = new Test();
        Scanner input = new Scanner(System.in);
        Lessons gaoshu = new Lessons(1, "高等数学", "101教室", "Mon-08:00");
        Lessons wuli = new Lessons(2, "大学物理", "102教室", "Mon-13:00");
        Lessons yingyu = new Lessons(3, "雅思英语", "201教室", "Wed-08:00");
        Lessons xiandai = new Lessons(4, "线性代数", "202教室", "Wed-13:00");
        Lessons lisan = new Lessons(5, "离散数学", "301教室", "Fir-08:00");
        Lessons Java = new Lessons(6, "Java", "304教室", "Fri-13:00");
        Lessons moren1[] = new Lessons[6];
        Lessons moren2[] = new Lessons[6];
        Teachers Zhao = new Teachers(1, "赵", "男", moren1);
        Students Qian = new Students(1, "钱同学", "女", moren2);
        int x = 0;
        while (true) {
            TS.fengexian();
            TS.menu1();
            x = input.nextInt();
            if (x == 1) {
                System.out.println("正在开课");
                TS.fengexian();
                System.out.println("可开课程为:" + "\n" + "0:" + gaoshu.lessons + "1:" + wuli.lessons
                        + "2:" + yingyu.lessons + "3:" +  xiandai.lessons + "4:" + lisan.lessons
                        + "5:" + Java.lessons);
                TS.fengexian();
                System.out.println("请输入开课号");
                int z = input.nextInt();
                Lessons moren[] = { gaoshu, wuli, yingyu, xiandai, lisan, Java };
                Zhao.OpenLessons(Zhao, z, moren[z]);
                moren[z].LessonTeacher = "赵老师";
                continue;
            }
            {
                TS.fengexian();
                TS.menu2();
                TS.fengexian();
                int s = input.nextInt();
                if (s == 1) {
                    TS.fengexian();
                    System.out.println("正在选课");
                    TS.fengexian();
                    System.out.println("可选课程为:" + "\n" + "0:" + gaoshu.lessons + "1:" + wuli.lessons
                            + "2:" + yingyu.lessons + "3:" +  xiandai.lessons + "4:" + lisan.lessons
                            + "5:" + Java.lessons);
                    TS.fengexian();
                    Lessons moren[] = { gaoshu, wuli, yingyu, xiandai, lisan, Java };
                    int j = input.nextInt();
                    Qian.ChoiceLessons(Qian, j, moren[j]);
                } else if (s == 2) {
                    System.out.println("正在退课");
                    TS.fengexian();
                    int p = input.nextInt();
                    Qian.OutLessons(Qian, p);
                } else {
                    TS.fengexian();
                    TS.reportError();
                    TS.fengexian();
                    break;
                }
                TS.fengexian();
                System.out.println("本次选课已结束，请确认信息");
                System.out.println("学生姓名：" + Qian.name + "\n" + "所选课程：" + "\n");
                for (int i = 0; i < 6; i++) {
                    if (Qian.lessons[i] == null) {
                        continue;
                    }
                    System.out.print(Qian.lessons[i].number + "｜" + Qian.lessons[i].lessons
                            + "｜" + Qian.lessons[i].place + "｜" + Qian.lessons[i].ClassTime + "｜"
                            + Qian.lessons[i].LessonTeacher + "\n");
                }
                TS.fengexian();
            }
            System.out.println("是否继续进行操作?" + "\n" + "1.继续" + "\n" + "2.结束");
            TS.fengexian();
            int y = input.nextInt();
            if (y == 1) {
                continue;
            } else if (y == 2)
                break;
            else {
                TS.fengexian();
                TS.reportError();
                TS.fengexian();
                break;
            }
        }
        input.close();
    }
}
